 //首页轮播图
    let CarouselMapLeft = document.getElementsByClassName("CarouselMapLeft")[0]
    //获取右边小图的所有元素
    let CarouselMapImg = document.getElementsByClassName("CarouselMapImg");
    let time;
    let index = 0;
    //设置一个重置函数
    function CarouselMapBox() {
        for (let i = 0; i < CarouselMapImg.length; i++) {
            CarouselMapImg[i].className = "CarouselMapImg"
        }
    }
    //设置一个选中函数
    let CarouselMapBoxTow = function () {
        CarouselMapBox();
        CarouselMapImg[index].className = "CarouselMapImg image";
    }
    CarouselMapLeft.style.backgroundImage = "url(../static_resources/img/1.jpg)";
    //设置启动轮播图的时间函数
    function turnOn() {
        time = setInterval(function () {
            CarouselMapBoxTow();
            index++;
            CarouselMapLeft.style.backgroundImage = "url(../static_resources/img/" + index + ".jpg)";
            if (index == 5) {
                index = 0;
            }
        }, 1500);
    }
    for (let i = 0; i < CarouselMapImg.length; i++) {
        //鼠标移动到当前小图片时触发
        CarouselMapImg[i].onmousemove = function () {
            //鼠标移动到当前小图片时左边变为当前小图片
            CarouselMapLeft.style.backgroundImage = "url(../static_resources/img/" + (i + 1) + ".jpg)";
            //鼠标移动到小图片上面时关闭定时器并重置定时，鼠标移开后再继续执行
            CarouselMapBox();
            clearInterval(time);
            index = i + 1;
            turnOn();
        }
    }
    //执行轮播图
    turnOn()

    //返回顶部
    let backToTop=document.getElementsByClassName("backToTop")[0];
    //onscroll()事件:div元素滚动时执行js
    document.addEventListener("scroll",function(){
        //获取当前页面滚动条纵坐标位置
        let distanceFromTop=document.documentElement.scrollTop;
        if(distanceFromTop>=300){
            backToTop.style.display="block";
        }else{
            backToTop.style.display="none";
        }
        //true表示传播方式为事件捕获传播(先分析外层再分析内层)，默认值为false(事件冒泡传播)(先分析内层再分析外层)
    },true);
    //俺一定速度返回顶部
    // backToTop.onclick=function()
    function backToTopFn(){
        var backTop=setInterval(function(){
            var topDistance=document.documentElement.scrollTop||document.body.scrollTop;
            if(topDistance>0){
                document.documentElement.scrollTop=document.body.scroll=topDistance-20;
            }else{
                clearInterval(backTop);
            }
        })
    }
    backToTop.addEventListener('click',function(){
        backToTopFn();
    })
    //上下浮动
    setInterval(function(){
        upAndDownFn()
    },600);

    function upAndDownFn(){
        backToTop.style.bottom="80px";
        setTimeout(function (){
            backToTop.style.bottom="50px";
        },300)
    }

    var DispClose = true;
    function CloseEvent()
    {
        if (DispClose)
        {
            // return "是否离开当前页面?";
            localStorage.clear();    //清除所有的本地缓存
        }
    }
    function UnLoadEvent()
    {
        DispClose = false;
    }
    let source=document.getElementsByClassName("source");
    let videoWindowContent=document.getElementsByClassName("videoWindowContent")[0];
    let deleteS=document.getElementsByClassName("deleteS")[0];
    let BigVideo=document.getElementsByClassName("BigVideo")[0];
    let sourceVideo=document.getElementsByClassName("sourceVideo");
    for(let i=0;i<source.length;i++){
        source[i].onclick=function(){
            videoWindowContent.style.display="block";
            BigVideo.src=sourceVideo[i].src;
        }
    }
    deleteS.addEventListener('click',function(){
        videoWindowContent.style.display="none";
    },true);
    let checkMore=document.getElementsByClassName("checkMore");
    checkMore[2].style.display="none";
    let newStenContent=document.getElementsByClassName("newStenContent");

 for(let i=0;i<newStenContent.length;i++){
     let re1 = new RegExp("<.+?>","g");//匹配html标签的正则表达式，"g"是搜索匹配多个符合的内容
     let msg = newStenContent[i].innerText.replace(re1,'');//执行替换成空字符
     newStenContent[i].innerHTML=msg;
 }
/*判断是否是vip*/
 let vipArticleContent=document.getElementsByClassName("vipArticleContent");
 for(let i=0;i<vipArticleContent.length;i++){
     if(sessionStorage.getItem("vip")==0){
         vipArticleContent[i].onclick=function(){

         }
     }else{
         vipArticleContent[i].onclick=function(){
             location.href=this.getAttribute('href');
         }
     }
 }
 let blogId=document.getElementsByClassName("blogId");
 let blogIdT=document.getElementsByClassName("blogIdT");
 let topNewLeftSix=document.getElementsByClassName("topNewLeftSix");
 let homepageBoxS=document.getElementsByClassName("homepageBoxS");
 for(let i=0;i<topNewLeftSix.length;i++){
     topNewLeftSix[i].onclick=function(){
         VIP(sessionStorage.getItem("id"),blogId[i].innerHTML,topNewLeftSix[i]);
     }
     homepageBoxS[i].onclick=function(){
         location.href=this.getAttribute('href');
         VIP(sessionStorage.getItem("id"),blogIdT[i].innerHTML,homepageBoxS[i]);
     }
 }

 let articleContent=document.getElementsByClassName("articleContent");
 for(let i=0;i<articleContent.length;i++){
     let re1 = new RegExp("<.+?>","g");//匹配html标签的正则表达式，"g"是搜索匹配多个符合的内容
     let msg = articleContent[i].innerText.replace(re1,'');//执行替换成空字符
     articleContent[i].innerHTML=msg;
 }
function VIP(idq,bidq,T){
     $.ajax({
         url:'../blog/isVIP',
         type:'post',
         data:{
             id:idq,
             bid:bidq
         },
         success:function(data){
             console.log(data)
             if(data.msg=="可以阅读"){
                 location.href=T.getAttribute('href');
             }else{
                alert(data.msg);
             }
         }
     });
}